package com.boot;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SpringMVCConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration loginRegistration = registry.addInterceptor(new LoginInterceptor());
        loginRegistration.addPathPatterns("/**");
        loginRegistration.excludePathPatterns("/user/tologin", "/user/dologin", "/user/permissionDenied", "/assets/**/*.*", "/image/**/*.*", "/vendors/**/*.*");

        InterceptorRegistration RoleRegistration = registry.addInterceptor(new RoleInterceptor());
        RoleRegistration.addPathPatterns("/**");
        RoleRegistration.excludePathPatterns("/user/tologin", "/user/dologin", "/user/permissionDenied", "/assets/**/*.*", "/image/**/*.*", "/vendors/**/*.*");
    }
}
